package com.lei2j.templateMethod;

import org.junit.Test;

import javax.swing.*;
import java.awt.*;

/**
 * Created by lei2j on 2019/1/27.
 */
public class TestTemplateMethod {

    @Test
    public void test1(){
        Tea tea = new Tea();
        tea.setAddCondiments(true);
        tea.prepareRecipe();
        System.out.println("===========");
        CaffeineBeverage coffee = new Coffee();
        coffee.prepareRecipe();
    }

    @Test
    public void test2() throws InterruptedException {
        new MyFrame("test");
        Thread.sleep(4000);
    }

    public static class MyFrame extends JFrame{

        public MyFrame(String title){
            super(title);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.setSize(300,300);
            this.setVisible(true);
        }

        public void paint(Graphics graphics){
            super.paint(graphics);
            graphics.drawString("run",100,100);
        }
    }
}
